package com.hao.baby.servlet;

import java.io.IOException;
import java.io.InputStream;

import javax.servlet.http.HttpServlet;

import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;

/**
 * Servlet implementation class InitServlet
 */
public class InitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private static final Log logger =  LogFactory.getLog(InitServlet.class);
       
    /**
     * @throws IOException 
     * @see HttpServlet#HttpServlet()
     */
    public InitServlet() throws IOException {
    	logger.info("加载Torque...");
		PropertiesConfiguration config = new PropertiesConfiguration();
		InputStream stream = InitServlet.class.getResourceAsStream("/Torque.properties");
		try {
			config.load(stream);
			Torque.init(config);
		} catch (org.apache.commons.configuration.ConfigurationException e) {
			e.printStackTrace();
		} catch (TorqueException e) {
			e.printStackTrace();
		}
    }
}
